import {
  fetchOperationList,
} from '@/services/merchants'

const TransModel = {
  namespace: 'trans',
  state: {
    record: [], // 选定地点
    freeRecord: [], // 指定包邮地区
    modalStatus: false,
    freeModal: false,
    proId: null,
    freeId: null,
    proName: undefined,
    freeCity: undefined,
    params: {},
    freeParams: {},
    current: null,
    details: {},
  },
  effects: {
    *fetchOperateList({ payload }, { call, put }) {
      const res =  yield call(getOperateByPermission, payload);

      if (res.code == 0) {
        const response = yield call(fetchOperationList);
        yield put({
          type: 'changeModelState',
          payload: {
            radioGroup: response.data,
            selected: res.data && res.data[0].id,
          },
        });
      }
    },
  },
  reducers: {
    update(state, action) {
      return {
        ...state,
        ...action.payload
      }
    },
    clear(state, action) {
      return {
        ...state,
      }
    }
  },
};
export default TransModel;